package com.cloudkinto.common.common;

import java.util.UUID;

public class CodeGenerator {
    private static PinyinTool pinyinTool = new PinyinTool();

    public static String generateCommonUUID() {
        return UUID.randomUUID().toString();
    }

    public static String generateResourceCode(String name) {
        try {
            return "RES_" + pinyinTool.toPinYin(name).trim() + "_" + generate4Number();
        } catch (Exception ex) {
            return "RES_" + name + "_" + generate4Number();
        }
    }

    public static String generate4Number() {
        RandomGenerator g = new RandomGenerator(4);
        return g.generateNum();
    }

    public static String generateMobileCode() {
        RandomGenerator g = new RandomGenerator(6);
        return g.generateNum();
    }

    public static String generateRandomPassword() {
        RandomGenerator g = new RandomGenerator(6);
        return g.generate();
    }

    public static String generateRandomUsername() {
        RandomGenerator g = new RandomGenerator(6);
        return "用户" + g.generateNum();
    }

    public static String generateRandomUserid() {
        RandomGenerator g = new RandomGenerator(10);
        return g.generateNum();
    }


}
